<template>
	<view class="confirm-page">
		<view v-for="(item,index ) in dataInfo" :key="index">
			{{item}}
		</view>

		<view class="data">
			<text class="title">
				<image style="width: 250rpx; height: 210rpx;" src="../../../static/images/pcIcon.png" mode=""></image>
			</text>
			<view class="info">
				<text>是否登录PC端</text>
			</view>

		</view>
		<view class="buttons button_login">
			
			<button @click="confirmLogin" class="confirm-btn button_true">
				登录
			</button>
			<button @click="cancelLogin" class="cancel-btn button_false" style="border: none;">
				取消登录
			</button>
			
<!-- 				<button @click="token" class="cancel-btn button_false" style="border: none;">
				token
			</button>
			
			<button @click="removetoken" class="cancel-btn button_false" style="border: none;">
				removetoken
			</button> -->
	 		<button @click="remove" class="cancel-btn button_false" style="border: none;">
				删除
			</button>

		</view>
	</view>
</template>

<script>
	import {
		getToken,
		getUserTokenInfo,
		removeToken,
		removeUserTokenInfo,
		setUserTokenInfo
	} from '../../../utils/auth'

	export default {
		data() {
			return {
				dataInfo: [],
				uuid: null,
			}
		},
		onLoad(option) {
			this.dataInfo.push(option)
			this.uuid = option.uuid
			this.dataInfo.push(this.uuid)
		},

		onBackPress() {

			this.dataInfo.push('123')

		},
		onBackPress(options) {
			if (options.from === 'navigateBack') {
				return false;
			}
			uni.showModal({
				title: '提示',
				content: '是否退出当前页面？',
				success: function(res) {
					if (res.confirm) {
						this.$router.back();
						// this.$router.back();
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
			return true;
		},
		methods: {

			removetoken() {
				removeToken()
			},
			token() {
				this.formDataSet('78978998');
				this.formDataSet(getToken());
			},

			remove() {
				removeUserTokenInfo()
				this.dataInfo = []
				uni.showToast({
					title: '删除成功'
				});
			},

			async getUserInfo() {
				try {
					const credentials =
						'(MembersCredential|WorkerMembersCredential)&PhoneNumberCredential';
					const res = await this.sendCodeUserTopAuth(true, credentials, this.uuid)
					// const res = await this.userTopAuth(true, credentials)
					this.formDataSet(credentials);
					this.formDataSet(res);

				} catch (err) {
					this.formDataSet(err);
				}
			},
			formDataSet(form) {
				this.dataInfo.push(form)
				this.$router.back();
				this.$router.back();
			},

			confirmLogin() {
				console.log('登录确认');
				this.getUserInfo()
			},
			cancelLogin() {
				this.$router.back();
				console.log('登录取消');
			},
		}
	}
</script>

<style scoped lang="scss">
	.dataInfo {
		width: 100vw;
		height: auto;
	}

	.button_login {
		width: 100%;
		position: absolute;
		bottom: 150rpx;
		display: block !important;

		.button_true {
			width: 40%;
			border-radius: 40rpx;
			margin-bottom: 40rpx;
		}

		.button_false {
			background-color: transparent;
			border: 2rpx solid transparent;
			width: 40%;
			border-radius: 40rpx;
		}
	}

	.button_false::after {
		border: 2rpx solid transparent !important;
	}

	.confirm-page {
		width: 100vw;
		height: 100vh;
		background-color: #fff;
		color: #333;
		text-align: center;
		box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
		border-radius: 10px;
	}

	.data {
		width: 100%;
		position: absolute;
		top: 20%;
	}

	.title {
		font-size: 26px;
		color: #c72c41;
		margin-bottom: 20px;
	}

	.info {
		margin-top: 50rpx;
		font-weight: 700;
		margin-bottom: 20px;
		font-size: 30rpx;
	}

	.username {
		font-weight: bold;
		color: #c72c41;
	}

	.buttons {
		display: flex;
		justify-content: space-around;

	}

	.confirm-btn,
	.cancel-btn {
		width: 20%;
		/* padding: 15rpx; */
		background-color: #c72c41;
		color: #fff;
		border: none;
		border-radius: 15rpx;
		cursor: pointer;
		transition: background-color 0.3s;
	}

	.confirm-btn:hover,
	.cancel-btn:hover {
		background-color: #a5232e;
	}

	.cancel-btn {
		background-color: #f0f0f0;
		color: #c72c41;
	}

	.cancel-btn:hover {
		background-color: #e0e0e0;
	}
</style>